package name.jiaosha.air.iostorage.controller;

import java.util.ArrayList;
import java.util.List;

import name.jiaosha.air.AppConstants;
import name.jiaosha.air.iostorage.domain.Buy;
import name.jiaosha.air.iostorage.service.IStorageService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.ali8ba.common.PageInfo;

/**
 * 入库记录
 * 
 * @author xu
 * 
 */
@Controller
@RequestMapping("/admin/strorage")
public class InRecordController {

	@Autowired
	private IStorageService storageService;

	@RequestMapping("/inRecord")
	public ModelAndView FindRecord() {

		PageInfo<Buy> pageInfo = null;

		if (!AppConstants.DEBUG) {

			pageInfo = new PageInfo<Buy>();

			List<Buy> list = new ArrayList<Buy>();
			for (int i = 0; i < 20; i++) {
				Buy buy = new Buy();
				buy.setDocID("2010091000" + i);
				buy.setCreateMan("黄总" + i);
				buy.setHandler("张学友" + i);
				list.add(buy);
			}

		} else {

			pageInfo = storageService.getBuyListByComId(AppConstants.comId, 1,
					AppConstants.DEFAULT_SIZE);
		}

		ModelMap model = new ModelMap();
		model.addAttribute("root", pageInfo.getItemList());
		model.addAttribute("totalProperty", pageInfo.getTotalProperty());
		return new ModelAndView("jsonView", model);
	}

}
